package com.ruoyi.scale.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.scale.domain.ScaleTestGroup;
import com.ruoyi.scale.mapper.ScaleTestGroupMapper;
import com.ruoyi.scale.service.IScaleTestGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 测试组Service业务层处理
 *
 * @author dais
 * @date 2023-09-03
 */
@Service
public class ScaleTestGroupServiceImpl implements IScaleTestGroupService {
    @Autowired
    private ScaleTestGroupMapper scaleTestGroupMapper;

    /**
     * 查询测试组
     *
     * @param testProjectId 测试组主键
     * @return 测试组
     */
    @Override
    public ScaleTestGroup selectScaleTestGroupByTestProjectId(Long testProjectId) {
        return scaleTestGroupMapper.selectScaleTestGroupByTestProjectId(testProjectId);
    }

    /**
     * 查询测试组列表
     *
     * @param scaleTestGroup 测试组
     * @return 测试组
     */
    @Override
    public List<ScaleTestGroup> selectScaleTestGroupList(ScaleTestGroup scaleTestGroup) {
        return scaleTestGroupMapper.selectScaleTestGroupList(scaleTestGroup);
    }

    /**
     * 新增测试组
     *
     * @param scaleTestGroup 测试组
     * @return 结果
     */
    @Override
    public int insertScaleTestGroup(ScaleTestGroup scaleTestGroup) {
        scaleTestGroup.setCreateTime(DateUtils.getNowDate());
        return scaleTestGroupMapper.insertScaleTestGroup(scaleTestGroup);
    }

    /**
     * 修改测试组
     *
     * @param scaleTestGroup 测试组
     * @return 结果
     */
    @Override
    public int updateScaleTestGroup(ScaleTestGroup scaleTestGroup) {
        scaleTestGroup.setUpdateTime(DateUtils.getNowDate());
        return scaleTestGroupMapper.updateScaleTestGroup(scaleTestGroup);
    }

    /**
     * 批量删除测试组
     *
     * @param testProjectIds 需要删除的测试组主键
     * @return 结果
     */
    @Override
    public int deleteScaleTestGroupByTestProjectIds(Long[] testProjectIds) {
        return scaleTestGroupMapper.deleteScaleTestGroupByTestProjectIds(testProjectIds);
    }

    /**
     * 删除测试组信息
     *
     * @param testProjectId 测试组主键
     * @return 结果
     */
    @Override
    public int deleteScaleTestGroupByTestProjectId(Long testProjectId) {
        return scaleTestGroupMapper.deleteScaleTestGroupByTestProjectId(testProjectId);
    }
}
